package com.view;

import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;

public class LogTxtArea extends JTextArea implements MouseListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	protected JPopupMenu menu;

	public LogTxtArea() {
		super();
		menu = new JPopupMenu();
		JMenuItem mclearLog;
		mclearLog = new JMenuItem("清空日志");
		menu.add(mclearLog);
		mclearLog.addActionListener(e -> setText(""));
		addMouseListener(this);
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		if (SwingUtilities.isRightMouseButton(e)) {
			Point point = e.getPoint();
			menu.show(this, point.x, point.y);
		}
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub

	}

}
